package cn.iocoder.yudao.module.member.dal.mysql.banner;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.banner.BannerDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.banner.vo.*;

/**
 * banner管理 Mapper
 *
 * @author 谭万全
 */
@Mapper
public interface BannerMapper extends BaseMapperX<BannerDO> {

    default PageResult<BannerDO> selectPage(BannerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BannerDO>()
                .likeIfPresent(BannerDO::getBannerName, reqVO.getBannerName())
                .eqIfPresent(BannerDO::getImageUrl, reqVO.getImageUrl())
                .eqIfPresent(BannerDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BannerDO::getForwardUrl, reqVO.getForwardUrl())
                .eqIfPresent(BannerDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(BannerDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BannerDO::getId));
    }

    default List<BannerDO> selectList(BannerExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BannerDO>()
                .likeIfPresent(BannerDO::getBannerName, reqVO.getBannerName())
                .eqIfPresent(BannerDO::getImageUrl, reqVO.getImageUrl())
                .eqIfPresent(BannerDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BannerDO::getForwardUrl, reqVO.getForwardUrl())
                .betweenIfPresent(BannerDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BannerDO::getId));
    }

}
